var inputName = document.querySelector("#inputName"),
    inputPrice = document.querySelector("#inputPrice"),
    inputNum = document.querySelector("#inputNum"),
    add = document.querySelector("#add"),
    msg = document.querySelector("#msg")

    add.onclick = ()=>{
        var name = inputName.value,
            price = inputPrice.value,
            num = inputNum.value
        utils.fetchG("./api/V1/shop/add.php",{ name , price , num}).then(resp=>{
            if(resp.code == 200){
                msg.style.display = 'block'
                setTimeout(() => {
                    $('#myModal').modal('hide')
                   
                    msg.style.display = 'none'
                    setShop()
                }, 2000);
            }else{
                msg.innerHTML = "添加失败，请重试"
                msg.className = "text-danger"
                msg.style.display = 'block'
                setTimeout(() => {
                    inputName.value = inputPrice.value = inputNum.value = ''
                    msg.style.display = 'none'
                    setShop()
                }, 2000);
            }
            
        })

    }

    $('#myModal').on('hidden.bs.modal', function (e) {
        inputName.value = inputPrice.value = inputNum.value = ''
      })